
import {useDispatch,useSelector} from 'react-redux';
import { useEffect } from 'react';

// 导入 actionCreater
import {inscrement ,decrement ,addTonum} from './store/modiles/counterStore';
import { fetchChannlList } from './store/modiles/channelStore';

function APP(){  
    const {count} = useSelector(state => state.counter); 
    const {channelList} = useSelector(state =>state.channel);
 
    console.log(count ,channelList)
    const dispatch = useDispatch();

    useEffect(()=>{
        dispatch(fetchChannlList())
    },[dispatch])
    return (<div className=""> 
        <button onClick={()=>dispatch(inscrement())}>+</button>
            {count}
        <button onClick={()=>dispatch(decrement())}>-</button>

        <button onClick={()=>dispatch(addTonum(10))}>加10</button> 
        <button onClick={()=>dispatch(addTonum(20))}>加20</button>
        <ul>{channelList.map(i=><li key={i.id}>{i.title}</li>)}</ul>
    </div>)
}
export default(APP);